<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Groups/classes/PhpFox_ComponentMyGroupsLinks.class.php, $Author:  $ */



/** Component for display list of groups links
 * @version $Id: PhpFox_ComponentCategories.class.php
 *  Max Kovrigovich
 * @package module.groups
 */
class PhpFox_Mod_Groups_ComponentMyGroupsLinks extends BaseComponent
{
    /** Processing method
     */

    function process()
    {
        //check permissions
        $oSecurityService = App::getModuleService('Account', 'Security');
		/* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
		
    	if ( !App::checkUserAccess('groups', array('full', 'read_only'), false) )
		{
			return '';
		}		

        $oTpl = $this->_oModule->getTemplate();
        $oReq = &App::getRequest();
        $sUser = $oSecurityService->getCurrentUserLogin();

        $sUser = $oReq->get('name');
        $aGroups = $this->oDatabase->getRows("SELECT m.id, m.title FROM ". App::getT('group_member') ." p, ". App::getT('group_main') ." m WHERE p.user = '". $this->oDatabase->escape($sUser) ."' AND m.id = p.group_id ORDER BY p.time DESC LIMIT 0,5");
        $oTpl->assign(array(
            'sUser'            => $sUser,
            'aGroups'          => $aGroups,
        ));
        $sHtml = $oTpl->fetch('MyGroupsLinks.html');
        return $sHtml;
    }
}
?>